package com.ys.fordemo;

/**
 * @author CodeYang
 * @Description 打印菱形:
 * @Date 2020/12/7 21:06
 */
public class For07打印菱形 {


    public static void main(String[] args) {
        int n =7;
        for (int i = 1; i <=n; i++) {
           // 上半部分空格规律----->
            for (int j = 1; j <=n-i ; j++) {
                System.out.print(" ");
            }
            for (int j = n-i+1; j <n+i ; j++) {
                System.out.print("*");
            }
            System.out.println();
        }

        for (int i = n-1; i >= 1; i--) {
            // 这里空额必须少一:
            for (int j = 1; j <=(n-i); j++) {
                System.out.print(" ");
            }
            for (int j = n-i+1; j <n+i ; j++) {
                System.out.print("*");
            }
            System.out.println();
        }


    }
}
